package cn.cs.service;

import cn.cs.mapper.CsFactoryMapper;
import cn.cs.pojo.CsFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class CsFactoryService {
    
    @Resource
    private CsFactoryMapper factoryMapper;

    @RequestMapping(value = "/getCsFactoryById", method = RequestMethod.POST)
    public CsFactory getCsFactoryById(@RequestParam("id") String id) throws Exception{
        return factoryMapper.getCsFactoryById(id);
    }

    @RequestMapping(value = "/getCsFactoryByIdName", method = RequestMethod.POST)
    public CsFactory getCsFactoryByIdName(@RequestParam("factory_id") String factory_id, @RequestParam("factory_name") String factory_name) throws Exception{
        return factoryMapper.getCsFactoryByIdName(factory_id, factory_name);
    }

    @RequestMapping(value = "/getCsFactoryByUserName", method = RequestMethod.POST)
    public CsFactory getCsFactoryByUserName(@RequestParam("factoryCode") String username) throws Exception{
        return factoryMapper.getCsFactoryByUserName(username);
    }

    @RequestMapping(value = "/getCsFactoryListByMap", method = RequestMethod.POST)
    public List<CsFactory> getCsFactoryListByMap(@RequestBody Map<String, Object> param) throws Exception{
        return factoryMapper.getCsFactoryListByMap(param);
    }

    @RequestMapping(value = "/getCsFactoryCountByMap", method = RequestMethod.POST)
    public Integer getCsFactoryCountByMap(@RequestBody Map<String, Object> param) throws Exception{
        return factoryMapper.getCsFactoryCountByMap(param);
    }

    @RequestMapping(value = "/insertCsFactory", method = RequestMethod.POST)
    public Integer insertCsFactory(@RequestBody CsFactory csFactory) throws Exception{
        return factoryMapper.insertCsFactory(csFactory);
    }

    @RequestMapping(value = "/updateCsFactory", method = RequestMethod.POST)
    public Integer updateCsFactory(@RequestBody CsFactory csFactory) throws Exception{
        return factoryMapper.updateCsFactory(csFactory);
    }

    @RequestMapping(value = "/deleteCsFactoryById", method = RequestMethod.POST)
    public Integer deleteCsFactoryById(@RequestParam("id") String id) throws Exception{
        return factoryMapper.deleteCsFactoryById(id);
    }

}
